package drds.binlog.protocol.protocol_proto;

/**
 * Protobuf type {@code com.alibaba.otter.canal.protocol.Ack}
 */
public final class Ack extends
        com.google.protobuf.GeneratedMessageV3 implements
        // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.Ack)
        AckOrBuilder
{
    public static final int ERROR_CODE_FIELD_NUMBER = 1;
    public static final int ERROR_MESSAGE_FIELD_NUMBER = 2;
    private static final long serialVersionUID = 0L;
    // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Ack)
    private static final Ack DEFAULT_INSTANCE;
    private static final com.google.protobuf.Parser<Ack>
            parser = new com.google.protobuf.AbstractParser<Ack>()
    {
        @Override
        public Ack parsePartialFrom(
                com.google.protobuf.CodedInputStream input,
                com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                throws com.google.protobuf.InvalidProtocolBufferException
        {
            return new Ack(input, extensionRegistry);
        }
    };

    static
    {
        DEFAULT_INSTANCE = new Ack();
    }

    private int errorCodePresentCase_ = 0;
    private Object errorCodePresent_;
    private volatile Object errorMessage_;
    private byte memoizedIsInitialized = -1;

    ;

    // Use Ack.newBuilder() to construct.
    private Ack(com.google.protobuf.GeneratedMessageV3.Builder<?> builder)
    {
        super(builder);
    }

    private Ack()
    {
        errorMessage_ = "";
    }

    private Ack(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        this();
        if (extensionRegistry == null)
        {
            throw new NullPointerException();
        }
        int mutable_bitField0_ = 0;
        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
                com.google.protobuf.UnknownFieldSet.newBuilder();
        try
        {
            boolean done = false;
            while (!done)
            {
                int tag = input.readTag();
                switch (tag)
                {
                    case 0:
                        done = true;
                        break;
                    case 8:
                    {
                        errorCodePresentCase_ = 1;
                        errorCodePresent_ = input.readInt32();
                        break;
                    }
                    case 18:
                    {
                        String s = input.readStringRequireUtf8();

                        errorMessage_ = s;
                        break;
                    }
                    default:
                    {
                        if (!parseUnknownFieldProto3(
                                input, unknownFields, extensionRegistry, tag))
                        {
                            done = true;
                        }
                        break;
                    }
                }
            }
        } catch (com.google.protobuf.InvalidProtocolBufferException e)
        {
            throw e.setUnfinishedMessage(this);
        } catch (java.io.IOException e)
        {
            throw new com.google.protobuf.InvalidProtocolBufferException(
                    e).setUnfinishedMessage(this);
        } finally
        {
            this.unknownFields = unknownFields.build();
            makeExtensionsImmutable();
        }
    }

    public static final com.google.protobuf.Descriptors.Descriptor
    getDescriptor()
    {
        return BinlogPacket.protocol_Ack_descriptor;
    }

    public static Ack parseFrom(
            java.nio.ByteBuffer data)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return parser.parseFrom(data);
    }

    public static Ack parseFrom(
            java.nio.ByteBuffer data,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return parser.parseFrom(data, extensionRegistry);
    }

    public static Ack parseFrom(
            com.google.protobuf.ByteString data)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return parser.parseFrom(data);
    }

    public static Ack parseFrom(
            com.google.protobuf.ByteString data,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return parser.parseFrom(data, extensionRegistry);
    }

    public static Ack parseFrom(byte[] data)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return parser.parseFrom(data);
    }

    public static Ack parseFrom(
            byte[] data,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return parser.parseFrom(data, extensionRegistry);
    }

    public static Ack parseFrom(java.io.InputStream input)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseWithIOException(parser, input);
    }

    public static Ack parseFrom(
            java.io.InputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseWithIOException(parser, input, extensionRegistry);
    }

    public static Ack parseDelimitedFrom(java.io.InputStream input)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseDelimitedWithIOException(parser, input);
    }

    public static Ack parseDelimitedFrom(
            java.io.InputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseDelimitedWithIOException(parser, input, extensionRegistry);
    }

    public static Ack parseFrom(
            com.google.protobuf.CodedInputStream input)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseWithIOException(parser, input);
    }

    public static Ack parseFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseWithIOException(parser, input, extensionRegistry);
    }

    public static Builder newBuilder()
    {
        return DEFAULT_INSTANCE.toBuilder();
    }

    public static Builder newBuilder(Ack prototype)
    {
        return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
    }

    public static Ack getDefaultInstance()
    {
        return DEFAULT_INSTANCE;
    }

    public static com.google.protobuf.Parser<Ack> parser()
    {
        return parser;
    }

    @Override
    public final com.google.protobuf.UnknownFieldSet
    getUnknownFields()
    {
        return this.unknownFields;
    }

    @Override
    protected FieldAccessorTable
    internalGetFieldAccessorTable()
    {
        return BinlogPacket.protocol_Ack_fieldAccessorTable
                .ensureFieldAccessorsInitialized(
                        Ack.class, Builder.class);
    }

    public ErrorCodePresentCase
    getErrorCodePresentCase()
    {
        return ErrorCodePresentCase.forNumber(
                errorCodePresentCase_);
    }

    /**
     * <code>int32 error_code = 1;</code>
     */
    public int getErrorCode()
    {
        if (errorCodePresentCase_ == 1)
        {
            return (Integer) errorCodePresent_;
        }
        return 0;
    }

    /**
     * <pre>
     * if something like compression is not supported, erorr_message will tell about it.
     * </pre>
     * <p>
     * <code>string error_message = 2;</code>
     */
    public String getErrorMessage()
    {
        Object ref = errorMessage_;
        if (ref instanceof String)
        {
            return (String) ref;
        } else
        {
            com.google.protobuf.ByteString bs =
                    (com.google.protobuf.ByteString) ref;
            String s = bs.toStringUtf8();
            errorMessage_ = s;
            return s;
        }
    }

    /**
     * <pre>
     * if something like compression is not supported, erorr_message will tell about it.
     * </pre>
     * <p>
     * <code>string error_message = 2;</code>
     */
    public com.google.protobuf.ByteString
    getErrorMessageBytes()
    {
        Object ref = errorMessage_;
        if (ref instanceof String)
        {
            com.google.protobuf.ByteString b =
                    com.google.protobuf.ByteString.copyFromUtf8(
                            (String) ref);
            errorMessage_ = b;
            return b;
        } else
        {
            return (com.google.protobuf.ByteString) ref;
        }
    }

    @Override
    public final boolean isInitialized()
    {
        byte isInitialized = memoizedIsInitialized;
        if (isInitialized == 1) return true;
        if (isInitialized == 0) return false;

        memoizedIsInitialized = 1;
        return true;
    }

    @Override
    public void writeTo(com.google.protobuf.CodedOutputStream output)
            throws java.io.IOException
    {
        if (errorCodePresentCase_ == 1)
        {
            output.writeInt32(
                    1, (int) ((Integer) errorCodePresent_));
        }
        if (!getErrorMessageBytes().isEmpty())
        {
            com.google.protobuf.GeneratedMessageV3.writeString(output, 2, errorMessage_);
        }
        unknownFields.writeTo(output);
    }

    @Override
    public int getSerializedSize()
    {
        int size = memoizedSize;
        if (size != -1) return size;

        size = 0;
        if (errorCodePresentCase_ == 1)
        {
            size += com.google.protobuf.CodedOutputStream
                    .computeInt32Size(
                            1, (int) ((Integer) errorCodePresent_));
        }
        if (!getErrorMessageBytes().isEmpty())
        {
            size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, errorMessage_);
        }
        size += unknownFields.getSerializedSize();
        memoizedSize = size;
        return size;
    }

    @Override
    public boolean equals(final Object obj)
    {
        if (obj == this)
        {
            return true;
        }
        if (!(obj instanceof Ack))
        {
            return super.equals(obj);
        }
        Ack other = (Ack) obj;

        boolean result = true;
        result = result && getErrorMessage()
                .equals(other.getErrorMessage());
        result = result && getErrorCodePresentCase().equals(
                other.getErrorCodePresentCase());
        if (!result) return false;
        switch (errorCodePresentCase_)
        {
            case 1:
                result = result && (getErrorCode()
                        == other.getErrorCode());
                break;
            case 0:
            default:
        }
        result = result && unknownFields.equals(other.unknownFields);
        return result;
    }

    @Override
    public int hashCode()
    {
        if (memoizedHashCode != 0)
        {
            return memoizedHashCode;
        }
        int hash = 41;
        hash = (19 * hash) + getDescriptor().hashCode();
        hash = (37 * hash) + ERROR_MESSAGE_FIELD_NUMBER;
        hash = (53 * hash) + getErrorMessage().hashCode();
        switch (errorCodePresentCase_)
        {
            case 1:
                hash = (37 * hash) + ERROR_CODE_FIELD_NUMBER;
                hash = (53 * hash) + getErrorCode();
                break;
            case 0:
            default:
        }
        hash = (29 * hash) + unknownFields.hashCode();
        memoizedHashCode = hash;
        return hash;
    }

    @Override
    public Builder newBuilderForType()
    {
        return newBuilder();
    }

    @Override
    public Builder toBuilder()
    {
        return this == DEFAULT_INSTANCE
                ? new Builder() : new Builder().mergeFrom(this);
    }

    @Override
    protected Builder newBuilderForType(
            BuilderParent parent)
    {
        Builder builder = new Builder(parent);
        return builder;
    }

    @Override
    public com.google.protobuf.Parser<Ack> getParserForType()
    {
        return parser;
    }

    @Override
    public Ack getDefaultInstanceForType()
    {
        return DEFAULT_INSTANCE;
    }

    public enum ErrorCodePresentCase
            implements com.google.protobuf.Internal.EnumLite
    {
        ERROR_CODE(1),
        ERRORCODEPRESENT_NOT_SET(0);
        private final int value;

        private ErrorCodePresentCase(int value)
        {
            this.value = value;
        }

        /**
         * @deprecated Use {@link #forNumber(int)} instead.
         */
        @Deprecated
        public static ErrorCodePresentCase valueOf(int value)
        {
            return forNumber(value);
        }

        public static ErrorCodePresentCase forNumber(int value)
        {
            switch (value)
            {
                case 1:
                    return ERROR_CODE;
                case 0:
                    return ERRORCODEPRESENT_NOT_SET;
                default:
                    return null;
            }
        }

        public int getNumber()
        {
            return this.value;
        }
    }

    /**
     * Protobuf type {@code com.alibaba.otter.canal.protocol.Ack}
     */
    public static final class Builder extends
            com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
            // @@protoc_insertion_point(builder_implements:com.alibaba.otter.canal.protocol.Ack)
            AckOrBuilder
    {
        private int errorCodePresentCase_ = 0;
        private Object errorCodePresent_;
        private Object errorMessage_ = "";

        // Construct using BinlogPacket.Ack.newBuilder()
        private Builder()
        {
            maybeForceBuilderInitialization();
        }

        private Builder(
                BuilderParent parent)
        {
            super(parent);
            maybeForceBuilderInitialization();
        }

        public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor()
        {
            return BinlogPacket.protocol_Ack_descriptor;
        }

        @Override
        protected FieldAccessorTable
        internalGetFieldAccessorTable()
        {
            return BinlogPacket.protocol_Ack_fieldAccessorTable
                    .ensureFieldAccessorsInitialized(
                            Ack.class, Builder.class);
        }

        private void maybeForceBuilderInitialization()
        {
            if (com.google.protobuf.GeneratedMessageV3
                    .alwaysUseFieldBuilders)
            {
            }
        }

        @Override
        public Builder clear()
        {
            super.clear();
            errorMessage_ = "";

            errorCodePresentCase_ = 0;
            errorCodePresent_ = null;
            return this;
        }

        @Override
        public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType()
        {
            return BinlogPacket.protocol_Ack_descriptor;
        }

        @Override
        public Ack getDefaultInstanceForType()
        {
            return Ack.getDefaultInstance();
        }

        @Override
        public Ack build()
        {
            Ack result = buildPartial();
            if (!result.isInitialized())
            {
                throw newUninitializedMessageException(result);
            }
            return result;
        }

        @Override
        public Ack buildPartial()
        {
            Ack result = new Ack(this);
            if (errorCodePresentCase_ == 1)
            {
                result.errorCodePresent_ = errorCodePresent_;
            }
            result.errorMessage_ = errorMessage_;
            result.errorCodePresentCase_ = errorCodePresentCase_;
            onBuilt();
            return result;
        }

        @Override
        public Builder clone()
        {
            return (Builder) super.clone();
        }

        @Override
        public Builder setField(
                com.google.protobuf.Descriptors.FieldDescriptor field,
                Object value)
        {
            return (Builder) super.setField(field, value);
        }

        @Override
        public Builder clearField(
                com.google.protobuf.Descriptors.FieldDescriptor field)
        {
            return (Builder) super.clearField(field);
        }

        @Override
        public Builder clearOneof(
                com.google.protobuf.Descriptors.OneofDescriptor oneof)
        {
            return (Builder) super.clearOneof(oneof);
        }

        @Override
        public Builder setRepeatedField(
                com.google.protobuf.Descriptors.FieldDescriptor field,
                int index, Object value)
        {
            return (Builder) super.setRepeatedField(field, index, value);
        }

        @Override
        public Builder addRepeatedField(
                com.google.protobuf.Descriptors.FieldDescriptor field,
                Object value)
        {
            return (Builder) super.addRepeatedField(field, value);
        }

        @Override
        public Builder mergeFrom(com.google.protobuf.Message other)
        {
            if (other instanceof Ack)
            {
                return mergeFrom((Ack) other);
            } else
            {
                super.mergeFrom(other);
                return this;
            }
        }

        public Builder mergeFrom(Ack other)
        {
            if (other == Ack.getDefaultInstance()) return this;
            if (!other.getErrorMessage().isEmpty())
            {
                errorMessage_ = other.errorMessage_;
                onChanged();
            }
            switch (other.getErrorCodePresentCase())
            {
                case ERROR_CODE:
                {
                    setErrorCode(other.getErrorCode());
                    break;
                }
                case ERRORCODEPRESENT_NOT_SET:
                {
                    break;
                }
            }
            this.mergeUnknownFields(other.unknownFields);
            onChanged();
            return this;
        }

        @Override
        public final boolean isInitialized()
        {
            return true;
        }

        @Override
        public Builder mergeFrom(
                com.google.protobuf.CodedInputStream input,
                com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                throws java.io.IOException
        {
            Ack parsedMessage = null;
            try
            {
                parsedMessage = parser.parsePartialFrom(input, extensionRegistry);
            } catch (com.google.protobuf.InvalidProtocolBufferException e)
            {
                parsedMessage = (Ack) e.getUnfinishedMessage();
                throw e.unwrapIOException();
            } finally
            {
                if (parsedMessage != null)
                {
                    mergeFrom(parsedMessage);
                }
            }
            return this;
        }

        public ErrorCodePresentCase
        getErrorCodePresentCase()
        {
            return ErrorCodePresentCase.forNumber(
                    errorCodePresentCase_);
        }

        public Builder clearErrorCodePresent()
        {
            errorCodePresentCase_ = 0;
            errorCodePresent_ = null;
            onChanged();
            return this;
        }

        /**
         * <code>int32 error_code = 1;</code>
         */
        public int getErrorCode()
        {
            if (errorCodePresentCase_ == 1)
            {
                return (Integer) errorCodePresent_;
            }
            return 0;
        }

        /**
         * <code>int32 error_code = 1;</code>
         */
        public Builder setErrorCode(int value)
        {
            errorCodePresentCase_ = 1;
            errorCodePresent_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>int32 error_code = 1;</code>
         */
        public Builder clearErrorCode()
        {
            if (errorCodePresentCase_ == 1)
            {
                errorCodePresentCase_ = 0;
                errorCodePresent_ = null;
                onChanged();
            }
            return this;
        }

        /**
         * <pre>
         * if something like compression is not supported, erorr_message will tell about it.
         * </pre>
         * <p>
         * <code>string error_message = 2;</code>
         */
        public String getErrorMessage()
        {
            Object ref = errorMessage_;
            if (!(ref instanceof String))
            {
                com.google.protobuf.ByteString bs =
                        (com.google.protobuf.ByteString) ref;
                String s = bs.toStringUtf8();
                errorMessage_ = s;
                return s;
            } else
            {
                return (String) ref;
            }
        }

        /**
         * <pre>
         * if something like compression is not supported, erorr_message will tell about it.
         * </pre>
         * <p>
         * <code>string error_message = 2;</code>
         */
        public Builder setErrorMessage(
                String value)
        {
            if (value == null)
            {
                throw new NullPointerException();
            }

            errorMessage_ = value;
            onChanged();
            return this;
        }

        /**
         * <pre>
         * if something like compression is not supported, erorr_message will tell about it.
         * </pre>
         * <p>
         * <code>string error_message = 2;</code>
         */
        public com.google.protobuf.ByteString
        getErrorMessageBytes()
        {
            Object ref = errorMessage_;
            if (ref instanceof String)
            {
                com.google.protobuf.ByteString b =
                        com.google.protobuf.ByteString.copyFromUtf8(
                                (String) ref);
                errorMessage_ = b;
                return b;
            } else
            {
                return (com.google.protobuf.ByteString) ref;
            }
        }

        /**
         * <pre>
         * if something like compression is not supported, erorr_message will tell about it.
         * </pre>
         * <p>
         * <code>string error_message = 2;</code>
         */
        public Builder setErrorMessageBytes(
                com.google.protobuf.ByteString value)
        {
            if (value == null)
            {
                throw new NullPointerException();
            }
            checkByteStringIsUtf8(value);

            errorMessage_ = value;
            onChanged();
            return this;
        }

        /**
         * <pre>
         * if something like compression is not supported, erorr_message will tell about it.
         * </pre>
         * <p>
         * <code>string error_message = 2;</code>
         */
        public Builder clearErrorMessage()
        {

            errorMessage_ = getDefaultInstance().getErrorMessage();
            onChanged();
            return this;
        }

        @Override
        public final Builder setUnknownFields(
                final com.google.protobuf.UnknownFieldSet unknownFields)
        {
            return super.setUnknownFieldsProto3(unknownFields);
        }

        @Override
        public final Builder mergeUnknownFields(
                final com.google.protobuf.UnknownFieldSet unknownFields)
        {
            return super.mergeUnknownFields(unknownFields);
        }


        // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.Ack)
    }

}
